
public class Test {

	public static void testPreorderTree(){
		
		StringTree tree;
		
		System.out.println("building a preorder-tree to test right-right balancing: ");
		
		System.out.println("creating tree with root a: ");
		tree = new PreorderTree("a");
		System.out.println(tree);
		
		System.out.println("adding b: ");
		tree.add("b");
		System.out.println(tree);
		
		System.out.println("adding c: ");
		tree.add("c");
		System.out.println(tree);
		
		System.out.println("building a preorder-tree to test left-left balancing: ");
		
		System.out.println("creating tree with root c: ");
		tree = new PreorderTree("c");
		System.out.println(tree);
		
		System.out.println("adding b: ");
		tree.add("b");
		System.out.println(tree);
		
		System.out.println("adding a: ");
		tree.add("a");
		System.out.println(tree);
		
		System.out.println("building a preorder-tree to test left-right balancing: ");
		
		System.out.println("creating tree with root d: ");
		tree = new PreorderTree("d");
		System.out.println(tree);
		
		System.out.println("adding b: ");
		tree.add("b");
		System.out.println(tree);
		
		System.out.println("adding c: ");
		tree.add("c");
		System.out.println(tree);
		
		System.out.println("building a preorder-tree to test right-left balancing: ");
		
		System.out.println("creating tree with root d: ");
		tree = new PreorderTree("d");
		System.out.println(tree);
		
		System.out.println("adding i: ");
		tree.add("i");
		System.out.println(tree);
		
		System.out.println("adding f: ");
		tree.add("f");
		System.out.println(tree);
		
	}

	public static void main(String[] args) {
		
		try{
		testPreorderTree();
		} catch(Exception e){
			System.out.println("exception in testPreorderTree! "+e.getMessage());
		}

		ReplaceableTree rt = new ReplaceableTree("a");
		
		rt.add("b");
		rt.add("c");
		rt.add("d");
		rt.add("e");
		rt.add("f");
		rt.add("g");
		rt.add("h");
		rt.add("i");
		
		System.out.println(rt.contains("z"));
		
		System.out.println(rt.search("h"));
		
		System.out.println(rt.toString());
		
		String treeString = "a\n- b\n - b1\n  - b11\n - b2\n- c\n - d\n - e\n  - f";
		
		rt.replace("left left left", treeString);
		
		System.out.println(rt.toString());
		
		IntTree it = new IntTree(1);
		
		it.add(2);
		it.add(3);
		it.add(4);
		it.add(5);
		it.add(6);
		
		System.out.println(it.contains(7));
		System.out.println(it.contains(3));
		
		System.out.println(it.search(5));
		
		System.out.println(it.toString());
		
		System.out.println("Testing traverse of SortedTrees:");
		
		PreorderTree prtr = new PreorderTree("g");
		prtr.add("a");
		prtr.add("b");
		prtr.add("z");
		prtr.add("h");
		System.out.println("Traverse of Preorder:");
		System.out.println(prtr.traverse());
		
		InorderTree intr = new InorderTree("g");
		intr.add("a");
		intr.add("b");
		intr.add("z");
		intr.add("h");
		System.out.println("Traverse of Inorder:");
		System.out.println(intr.traverse());
		
		PostorderTree potr = new PostorderTree("g");
		potr.add("a");
		potr.add("b");
		potr.add("z");
		potr.add("h");
		System.out.println("Traverse of Postorder:");
		System.out.println(potr.traverse());
		
	}
	
}
